package com.lnking.lnkingplace.controller;


import com.lnking.common.http.ReturnResult;
import com.lnking.lnkingplace.model.entity.PlaceInfo;
import com.lnking.lnkingplace.model.request.place.PlaceAddRequest;
import com.lnking.lnkingplace.model.request.place.PlaceUpdateRequest;
import com.lnking.lnkingplace.model.request.userStreet.UserStreetAddRequest;
import com.lnking.lnkingplace.model.request.userStreet.UserStreetUpdateRequest;
import com.lnking.lnkingplace.service.IUserStreetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhangqt
 * @since 2022-08-23
 */
@RestController
@RequestMapping("/user-street")
@Api(tags = "网格员绑定街道")
public class UserStreetController {

    @Resource
    IUserStreetService userStreetService;

    @PostMapping("queryStreet")
    @ApiOperation("查询绑定街道")
    public ReturnResult queryStreet(@RequestBody String userId){

        return ReturnResult.success(userStreetService.queryStreet(userId));
    }

    @PostMapping("add")
    @ApiOperation("绑定街道")
    public ReturnResult add(@RequestBody UserStreetAddRequest params) throws Exception{
        userStreetService.add(params);
        return ReturnResult.success();
    }

    @PostMapping("update")
    @ApiOperation("修改绑定街道")
    public ReturnResult update(@RequestBody UserStreetUpdateRequest params) throws Exception{
        userStreetService.updateUserStreet(params);
        return ReturnResult.success();
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public ReturnResult delete(@PathVariable("id") String id) {
        userStreetService.removeById(id);
        return ReturnResult.success();
    }
}
